#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
int couple[100005];
int k[100005]={0};
 
int main(){
	int N, p1, p2;
	memset(couple, -1, sizeof(couple));  //单身 
	scanf("%d",&N);
	while(N--){
		scanf("%d%d",&p1,&p2);
		couple[p1]=p2;  
		couple[p2]=p1;
	}
	int M, p;
	scanf("%d",&M);
	while(M--){
		scanf("%d",&p);
		if(couple[p]==-1) {  //肯定是单身 
			k[p] = 1;
		}else{
			if(couple[couple[p]]==-2){
				k[couple[p]]=0; 
			}else{  //可能是单身 
				k[p] = 1;   
				couple[p] = -2; 
			} 	
		}
	}
	int count=0;
	for(int i=0; i<100005; i++){
		if(k[i]){
			count++;
		}
	}
    printf("%d\n", count);

    int l=0;
    for(int i=0; i<100005; i++)
    {
        if(k[i]){
			if(l==1)
			    printf(" %05d", i);
			if(l==0){
			    printf("%05d", i);
				l=1;
			}
		}

    }
	return 0;
}